from flask import (
    Flask,
    Blueprint,
    request,
)
from flask_apscheduler import APScheduler
main = Blueprint('my_scheduler', __name__)

class Config(object):  # 创建配置，用类
    JOBS = [  # 任务列表
        {  # 任务字典（细节）
            'id': 'alive_server_check_LTC',
            'func': 'routes.cloudoss.alive_check:test_alive_check_from_nginx_LTC',
            # 'args': (1, 2),
            'trigger': 'interval',
          #  'hour': 0,
          #  'minute': 1
            'seconds': 90
        },
        {  # 任务字典（细节）
            'id': 'alive_server_check_SIT',
            'func': 'routes.cloudoss.alive_check:test_alive_check_from_nginx_SIT',
            # 'args': (1, 2),
            'trigger': 'interval',
          #  'hour': 0,
          #  'minute': 1
            'seconds': 90
        },
    ]

# app = Flask(__name__)
# app.config.from_object(Config())
scheduler = APScheduler()
# scheduler.init_app(app)
# scheduler.start()
# app.run()

@main.route('/pause')
def pausejob():
    scheduler.pause_job('alive_server_check')
    return "Success!"

@main.route('/resume')
def resumejob():
    scheduler.resume_job('alive_server_check')
    return "Success!"

@main.route('/start', methods=['GET', 'POST'])
def addjob():
    scheduler.start()
#
# @main.route('/')
# def resumejob():
#     return "scheduler!"